const data = [
    {
        id: 1,
        text: '节点1',
        parentId: 0,
        children: [
            {
                id: 2,
                text: '节点1_1',
                parentId: 1
            }
        ]
    }
]

function treeToList(data) {
    let res = []
    let dfs = (data) => {
        data.forEach(item => {
            const {id,text,parentId,children} = item
            res.push({
                id : id,
                text : text,
                parentId : parentId
            })
            if (children) dfs(children)
        })

    }
    dfs(data)
    return res
}

console.log(treeToList(data));

